package timing.ukulele.third.controller.msg;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import timing.ukulele.common.data.ResponseData;
import timing.ukulele.data.third.data.msg.MessageNoticeItemMappingFiledDTO;
import timing.ukulele.data.third.view.msg.MessageNoticeItemMappingFiledVO;
import timing.ukulele.third.service.msg.MessageNoticeItemMappingFiledService;

/**
 * 消息通知事项映射字段管理接口
 *
 * @author zh
 */
@RestController
@RequestMapping("/msg/messageNoticeItemMappingFiled")
@Slf4j
public class MessageNoticeItemMappingFiledController {

    private final MessageNoticeItemMappingFiledService service;

    public MessageNoticeItemMappingFiledController(MessageNoticeItemMappingFiledService service) {
        this.service = service;
    }

    /**
     * /msg/messageNoticeItemMappingFiled/add
     * @param dto
     * @return
     */
    @PostMapping("/add")
    @Operation(summary = "新增消息通知事项映射字段")
    public ResponseData<Boolean> addMappingFiled(@RequestBody MessageNoticeItemMappingFiledDTO dto) {
        return ResponseData.success(service.addMappingFiled(dto));
    }

    /**
     * /msg/messageNoticeItemMappingFiled/update
     * @param dto
     * @return
     */
    @PutMapping("/update")
    @Operation(summary = "修改消息通知事项映射字段")
    public ResponseData<Boolean> updateMappingFiled(@RequestBody MessageNoticeItemMappingFiledDTO dto) {
        return ResponseData.success(service.updateMappingFiled(dto));
    }

    /**
     * /msg/messageNoticeItemMappingFiled/deleteMessageNoticeItem
     * @param id
     * @return
     */
    @DeleteMapping("/delete")
    @Operation(summary = "删除消息通知事项映射字段")
    public ResponseData<Boolean> deleteMappingFiled(@RequestParam("id") Long id) {
        return ResponseData.success(service.deleteMappingFiled(id));
    }

    /**
     * /msg/messageNoticeItemMappingFiled/page
     * @param dto
     * @return
     */
    @GetMapping("/page")
    @Operation(summary = "消息通知事项映射字段分页列表")
    public ResponseData<IPage<MessageNoticeItemMappingFiledVO>> page(MessageNoticeItemMappingFiledDTO dto) {
        return ResponseData.success(service.pageList(dto));
    }

}
